// pages/tianxie/tianxie.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    sdate: '',
    edate: '',
    stime: '',
    etime: '',
    titleColor: '#8D4ABC',
    okColor: '',
    tiaoColor: ''
  },
  onLoad() {
    let dd = new Date()
    let d = dd.getFullYear() + "/" + (dd.getMonth() + 1) + "/" + dd.getDate();
    this.setData({
      sdate: d,
      edate: d
    })
    console.log(this.data.sdate)
  },
  submit(event) {
    let user = event.detail.value
    if (!user.gowhere) {
      user.gowhere = "市人民医院"
    }
    if (!user.college) {
      user.college = "计算机科学与信息工程学院"
    }
    if (user.pro2) {
      user.pro1 = user.pro2
    }
    user.start = this.data.sdate + ' ' + this.data.stime
    user.end = this.data.edate + ' ' + this.data.etime
    if (user.name && user.num && user.reason) {
      wx.setStorageSync('user', user)
      wx.navigateBack({
        delta: 1
      })
    } else {
      wx.showModal({
        showCancel: false,
        content: '完整填写姓名或学号或理由'
      })
    }
  },
  bindsDateChange: function (e) {
    console.log('picker发送选择改变，携带值为', e.detail.value)
    this.setData({
      sdate: e.detail.value.replace(new RegExp('-', 'g'), '/')
    })
  },
  bindsTimeChange: function (e) {
    console.log('picker发送选择改变，携带值为', e.detail.value)
    this.setData({
      stime: e.detail.value
    })
  },
  bindeDateChange: function (e) {
    console.log('picker发送选择改变，携带值为', e.detail.value)
    this.setData({
      edate: e.detail.value.replace(new RegExp('-', 'g'), '/')
    })
  },
  bindeTimeChange: function (e) {
    console.log('picker发送选择改变，携带值为', e.detail.value)
    this.setData({
      etime: e.detail.value
    })
  }
})